/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.helpdesk.entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Manuel
 */
@Entity
@Table(name = "hd_asesor")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HdAsesor.findAll", query = "SELECT h FROM HdAsesor h"),
    @NamedQuery(name = "HdAsesor.findByCodAsesor", query = "SELECT h FROM HdAsesor h WHERE h.codUsuario.codUsuario = :codUsuario")})
public class HdAsesor implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy= GenerationType.TABLE, generator="ASESORES")
    @TableGenerator(name="ASESORES", 
                    table="tbsequence",
                    pkColumnName="seq_name",
                    valueColumnName="seq_count")
    @Column(name = "COD_ASESOR", nullable=false)
    @Basic(optional = false)
    @NotNull
    private Integer codAsesor;
    @OneToMany(mappedBy = "codAsesor")
    private List<HdTickets> hdTicketsList;
    @JoinColumn(name = "COD_USUARIO", referencedColumnName = "COD_USUARIO")
    @ManyToOne(optional = false)
    private HdUsuarios codUsuario;

    public HdAsesor() {
    }

    public HdAsesor(Integer codAsesor) {
        this.codAsesor = codAsesor;
    }

    public Integer getCodAsesor() {
        return codAsesor;
    }

    public void setCodAsesor(Integer codAsesor) {
        this.codAsesor = codAsesor;
    }

    @XmlTransient
    public List<HdTickets> getHdTicketsList() {
        return hdTicketsList;
    }

    public void setHdTicketsList(List<HdTickets> hdTicketsList) {
        this.hdTicketsList = hdTicketsList;
    }

    public HdUsuarios getCodUsuario() {
        return codUsuario;
    }

    public void setCodUsuario(HdUsuarios codUsuario) {
        this.codUsuario = codUsuario;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codAsesor != null ? codAsesor.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HdAsesor)) {
            return false;
        }
        HdAsesor other = (HdAsesor) object;
        if ((this.codAsesor == null && other.codAsesor != null) || (this.codAsesor != null && !this.codAsesor.equals(other.codAsesor))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
       return codUsuario.getNomUsuario()+" "+codUsuario.getApeUsuarios();
        
    }
    
}
